GMMMPEC_f_ktr_FE <- function(x) { 

x<-as.matrix(x) 

g = x[((nD+1)*(K_A+1) + (countries-1) + nD + numProdsTotal+1):nrow(x), 1] 

f<-t(g)%*%W%*%g 
    
return(f)
  
}  